package mipushdemo.xiaomi.com.diyitonghang.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

import mipushdemo.xiaomi.com.diyitonghang.app.MyContext;

public class HttpNetUtil {
    private static HttpNetUtil httpNetUtil;

    private  HttpNetUtil() {
    }

    public static HttpNetUtil getInstance(){
        if(httpNetUtil == null){
            synchronized (HttpNetUtil.class){
                httpNetUtil = new HttpNetUtil();
            }
        }
        return httpNetUtil;
    }


    protected static boolean isNetworkConnected() {
        final ConnectivityManager connManager = (ConnectivityManager) MyContext.getInstance()
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        final NetworkInfo netInfo = connManager.getActiveNetworkInfo();
        if (netInfo != null && netInfo.getState() == NetworkInfo.State.CONNECTED) {
            return true;
        }
        return false;
    }
}
